﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;

namespace Dycox.Drawing
{
    public class DiagramEndPoint
    {
        public DiagramEndPoint(DiagramShape targetShape, int hotPointID)
        {
            if (targetShape == null)
                throw new ArgumentNullException("targetShape");

            _targetShape = targetShape;
            _hotPointID = hotPointID;

            _targetShape.HotPointsChanged += _targetShape_HotPointsChanged;
        }

        void _targetShape_HotPointsChanged(object sender, EventArgs e)
        {
            OnLocationChanged(e);
        }

        private DiagramShape _targetShape;

        public DiagramShape TargetShape
        {
            get { return _targetShape; }
        }

        private int _hotPointID;

        public int HotPointID
        {
            get { return _hotPointID; }
        }

        public PointF Location
        {
            get
            {
                return _targetShape.GetHotPoint(_hotPointID).Location;
            }
        }

        public event EventHandler LocationChanged;

        protected void OnLocationChanged(EventArgs e)
        {
            if (LocationChanged != null)
                LocationChanged(this, e);
        }
    }

}
